package com.lindroy.androidplayer.ui.collection

import android.os.Bundle
import androidx.fragment.app.viewModels
import com.lindroy.androidplayer.R
import com.lindroy.androidplayer.base.BaseLazyFragment
import com.lindroy.androidplayer.databinding.FragmentMyCollectionBinding
import com.lindroy.androidplayer.ui.adapter.CollectionTabAdapter
import com.lindroy.androidplayer.utils.contactToViewPager
import com.lindroy.androidplayer.viewmodels.CollectionViewModel

/**
 * @author Lin
 * @date 2022/2/17
 * @function 我的收藏
 */
class MyCollectionFragment : BaseLazyFragment<FragmentMyCollectionBinding>() {

    private val tabs = arrayListOf<String>()

    private val viewModel by viewModels<CollectionViewModel>()

    override fun FragmentMyCollectionBinding.initView(savedInstanceState: Bundle?) {
        vm = viewModel
        tabs.clear()
        tabs.add(getString(R.string.collection_article))
        tabs.add(getString(R.string.collection_website))
        vpCollection.adapter =
            CollectionTabAdapter(this@MyCollectionFragment).apply { setData(tabs) }
        tab.tabLayout.contactToViewPager(vpCollection, tabs)
    }

    override fun FragmentMyCollectionBinding.initListener() {
        viewModel.backClickLiveData.observe(viewLifecycleOwner) {
            activityNavController.navigateUp()
        }
    }

    override fun lazyLoad() {
    }
}